/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.metaaps.eoclipse.io;

import java.util.List;
import java.util.Map;

import com.metaaps.eoclipse.api.GeometricLayer;
import com.metaaps.eoraster.EOImageReader;

/**
 *
 * @author thoorfr
 */
public abstract class VectorIO {

    protected EOImageReader gir;
    protected Map config;
    public static String SIMPLE_SHAPEFILE = "SimpleShapeFile";
    public static String GML = "GML";
    public static String POSTGIS = "Postgis";
    public static String CSV = "Csv";
    public static String GENERIC_CSV = "Generic Csv";
    public static String KML = "Kml";
    protected String layername;

    protected VectorIO() {
    }

    public void setLayerName(String layername) {
        this.layername = layername;
    }

    public static VectorIO createVectorIO(String type, Map config, EOImageReader gir) {
        if (type.equals(SIMPLE_SHAPEFILE)) {
            SimpleShapefileIO vio = new SimpleShapefileIO();
            vio.gir = gir;
            vio.config = config;
            return vio;
        } else if (type.equals(POSTGIS)) {
            PostgisIO vio = new PostgisIO();
            vio.gir = gir;
            vio.config = config;
            return vio;
        } else if (type.equals(GML)) {
            GmlIO gio = new GmlIO();
            gio.gir = gir;
            gio.config = config;
            return gio;
        } else if (type.equals(CSV)) {
            SimpleCSVIO csvio = new SimpleCSVIO();
            csvio.gir = gir;
            csvio.config = config;
            return csvio;
        } else if (type.equals(GENERIC_CSV)) {
            GenericCSVIO csvio = new GenericCSVIO();
            csvio.gir = gir;
            csvio.config = config;
            return csvio;
        } else if (type.equals(KML)) {
            KmlIO kmlio = new KmlIO();
            kmlio.gir = gir;
            kmlio.config = config;
            return kmlio;
        }
        return null;
    }

    public abstract GeometricLayer read();

    public abstract void save(GeometricLayer layer, String projection);

    /**
     * For some reasons, you may execute some commands for some special datastore (clening database, ensure existence, or manual upload...)
     * @param commands
     * @return List of  Objects that describe the results of the associated commands
     */
    public List<? extends Object> executeCommands(List<String> commands) {
        return null;
    }
}
